#include "widget.h"
#include "ui_widget.h"
#include "switchbutton.h"
#include <QWindow>
#include <QCursor>
#include <QTest>

#define CONFIG_COMMON "common"
#define CONFIG_OCR "ocr"
#define CONFIG_EXAM "exam"
#define SUBJECT_JP "jp"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    initializing = true;
    screen = QApplication::primaryScreen();
    state = 0;
    ui->setupUi(this);
    this->setMouseTracking(true);
    currentTab = ui->tabWidget->currentIndex();
    changeTab(currentTab);
    connect(ui->tabWidget, &QTabWidget::currentChanged, this, &Widget::changeTab);

    connect(ui->startButton, &QPushButton::clicked, this, &Widget::start);
    connect(ui->pauseButton, &QPushButton::clicked, this, &Widget::pause);
    connect(ui->stopButton, &QPushButton::clicked, this, &Widget::stop);
    initFunctionKeys();
    initListJP();
    connect(ui->startCombobox, &QComboBox::currentIndexChanged, this, &Widget::selectStartKey);
    connect(ui->pauseCombobox, &QComboBox::currentIndexChanged, this, &Widget::selectPauseKey);
    connect(ui->stopComboBox, &QComboBox::currentIndexChanged, this, &Widget::selectStopKey);
    connect(ui->bindButton, &QPushButton::clicked, this, &Widget::tryBindingWindow);

    connect(ui->quitModeCombobox, &QComboBox::currentIndexChanged, this, &Widget::selectQuitMode);
    connect(ui->soundSwitchButton, &SwitchButton::statusChanged, this, &Widget::toggleSoundSwitch);

    connect(ui->generalSwitch1, &SwitchButton::statusChanged, this, &Widget::toggleGeneralSwitch1);
    connect(ui->generalKey1, &QKeySequenceEdit::editingFinished, this, &Widget::setGeneralKey1);
    connect(ui->generalInterval1, &QSpinBox::editingFinished, this, &Widget::setGeneralInterval1);
    connect(ui->generalSwitch2, &SwitchButton::statusChanged, this, &Widget::toggleGeneralSwitch2);
    connect(ui->generalKey2, &QKeySequenceEdit::editingFinished, this, &Widget::setGeneralKey2);
    connect(ui->generalInterval2, &QSpinBox::editingFinished, this, &Widget::setGeneralInterval2);
    connect(ui->generalSwitch3, &SwitchButton::statusChanged, this, &Widget::toggleGeneralSwitch3);
    connect(ui->generalKey3, &QKeySequenceEdit::editingFinished, this, &Widget::setGeneralKey3);
    connect(ui->generalInterval3, &QSpinBox::editingFinished, this, &Widget::setGeneralInterval3);
    connect(ui->generalSwitch4, &SwitchButton::statusChanged, this, &Widget::toggleGeneralSwitch4);
    connect(ui->generalKey4, &QKeySequenceEdit::editingFinished, this, &Widget::setGeneralKey4);
    connect(ui->generalInterval4, &QSpinBox::editingFinished, this, &Widget::setGeneralInterval4);

    connect(ui->selectSubjectButton, &QPushButton::clicked, this, &Widget::selectSubjectRect);
    connect(ui->selectOptionButton, &QPushButton::clicked, this, &Widget::selectOptionRect);
    connect(ui->pickConfirmationButton, &QPushButton::clicked, this, &Widget::pickConfirmation);
    connect(ui->pickSubmissionButton, &QPushButton::clicked, this, &Widget::pickSubmission);

    soundEffect = new QSoundEffect(this);
    initTray();
    config = new Config("config");
    loadConfiguration();
    loadExamConfiguration();
    subjects = new Config("subjects");
    initSubjects();
    detectWords = new DetectWords();
    getOcrAccessToken();
    hook.installHook(GlobalHook::eMouseKey);
    connect(&hook, &GlobalHook::keyEventReceived, this, &Widget::onKeyEventReceived);
    connect(&hook, &GlobalHook::mouseEventReceived, this, &Widget::onMouseEventReceived);
    initializing = false;
}

Widget::~Widget()
{
    delete ui;
    hook.unInstallHook(GlobalHook::eMouseKey);
}

void Widget::loadConfiguration()
{
    QVariant startSetting = config->readConfig(CONFIG_COMMON, "start");
    if (startSetting.isNull())
    {
        startKey = VK_F12;
    }
    else
    {
        startKey = startSetting.toInt();
    }
    ui->startCombobox->setCurrentText(functionKeys[startKey]);
    ui->startButton->setText("开始 (" + functionKeys[startKey] + ")");

    QVariant pauseSetting = config->readConfig(CONFIG_COMMON, "pause");
    if (pauseSetting.isNull())
    {
        pauseKey = VK_F11;
    }
    else
    {
        pauseKey = pauseSetting.toInt();
    }
    ui->pauseButton->setText("暂停 (" + functionKeys[pauseKey] + ")");
    ui->pauseCombobox->setCurrentText(functionKeys[pauseKey]);

    QVariant stopSetting = config->readConfig(CONFIG_COMMON, "stop");
    if (stopSetting.isNull())
    {
        stopKey = VK_F12;
    }
    else
    {
        stopKey = stopSetting.toInt();
    }
    ui->stopComboBox->setCurrentText(functionKeys[stopKey]);
    ui->stopButton->setText("结束 (" + functionKeys[stopKey] + ")");

    QVariant quitModeSetting = config->readConfig(CONFIG_COMMON, "quitMode");
    if (!quitModeSetting.isNull())
    {
        quitMode = quitModeSetting.toInt();
    }
    ui->quitModeCombobox->setCurrentIndex(quitMode);

    QVariant soundSwitchSetting = config->readConfig(CONFIG_COMMON, "soundSwitch");
    if (!quitModeSetting.isNull())
    {
        soundSwitch = soundSwitchSetting.toBool();
    }
    ui->soundSwitchButton->setCheckedState(soundSwitch);
    // 加载常规按键信息-开始
    QVariant generalSwitch1Setting = config->readConfig(CONFIG_COMMON, "generalSwitch1");
    if (!generalSwitch1Setting.isNull())
    {
        generalSwitch1 = generalSwitch1Setting.toBool();
    }
    ui->generalSwitch1->setCheckedState(generalSwitch1);

    QVariant generalKey1Setting = config->readConfig(CONFIG_COMMON, "generalKey1");
    if (!generalKey1Setting.isNull())
    {
        generalKey1 = generalKey1Setting.toInt();
    }
    ui->generalKey1->setKeySequence(QKeySequence(generalKey1));

    QVariant generalInterval1Setting = config->readConfig(CONFIG_COMMON, "generalInterval1");
    if (!generalInterval1Setting.isNull())
    {
        generalInterval1 = generalInterval1Setting.toInt();
    }
    ui->generalInterval1->setValue(generalInterval1);

    QVariant generalSwitch2Setting = config->readConfig(CONFIG_COMMON, "generalSwitch2");
    if (!generalSwitch2Setting.isNull())
    {
        generalSwitch2 = generalSwitch2Setting.toBool();
    }
    ui->generalSwitch2->setCheckedState(generalSwitch2);

    QVariant generalKey2Setting = config->readConfig(CONFIG_COMMON, "generalKey2");
    if (!generalKey2Setting.isNull())
    {
        generalKey2 = generalKey2Setting.toInt();
    }
    ui->generalKey2->setKeySequence(QKeySequence(generalKey2));

    QVariant generalInterval2Setting = config->readConfig(CONFIG_COMMON, "generalInterval2");
    if (!generalInterval2Setting.isNull())
    {
        generalInterval2 = generalInterval2Setting.toInt();
    }
    ui->generalInterval2->setValue(generalInterval2);

    QVariant generalSwitch3Setting = config->readConfig(CONFIG_COMMON, "generalSwitch3");
    if (!generalSwitch3Setting.isNull())
    {
        generalSwitch3 = generalSwitch3Setting.toBool();
    }
    ui->generalSwitch3->setCheckedState(generalSwitch3);

    QVariant generalKey3Setting = config->readConfig(CONFIG_COMMON, "generalKey3");
    if (!generalKey3Setting.isNull())
    {
        generalKey3 = generalKey3Setting.toInt();
    }
    ui->generalKey3->setKeySequence(QKeySequence(generalKey3));

    QVariant generalInterval3Setting = config->readConfig(CONFIG_COMMON, "generalInterval3");
    if (!generalInterval3Setting.isNull())
    {
        generalInterval3 = generalInterval3Setting.toInt();
    }
    ui->generalInterval3->setValue(generalInterval3);

    QVariant generalSwitch4Setting = config->readConfig(CONFIG_COMMON, "generalSwitch4");
    if (!generalSwitch4Setting.isNull())
    {
        generalSwitch4 = generalSwitch4Setting.toBool();
    }
    ui->generalSwitch4->setCheckedState(generalSwitch4);

    QVariant generalKey4Setting = config->readConfig(CONFIG_COMMON, "generalKey4");
    if (!generalKey4Setting.isNull())
    {
        generalKey4 = generalKey4Setting.toInt();
    }
    ui->generalKey4->setKeySequence(QKeySequence(generalKey4));

    QVariant generalInterval4Setting = config->readConfig(CONFIG_COMMON, "generalInterval4");
    if (!generalInterval4Setting.isNull())
    {
        generalInterval4 = generalInterval4Setting.toInt();
    }
    ui->generalInterval4->setValue(generalInterval4);
    // 加载常规按键信息-结束
}

void Widget::loadExamConfiguration()
{
    QVariant subjectStartPointSetting = config->readConfig(CONFIG_EXAM, "subjectStartPoint");
    QVariant subjectEndPointSetting = config->readConfig(CONFIG_EXAM, "subjectEndPoint");
    if (!subjectStartPointSetting.isNull() && !subjectEndPointSetting.isNull())
    {
        ui->selectSubjectButton->setProperty("rectSelected", true);
        ui->selectSubjectButton->style()->polish(ui->selectSubjectButton);
        subjectStartPoint = QPoint(subjectStartPointSetting.toString().split(",").at(0).toInt(), subjectStartPointSetting.toString().split(",").at(1).toInt());
        subjectEndPoint = QPoint(subjectEndPointSetting.toString().split(",").at(0).toInt(), subjectEndPointSetting.toString().split(",").at(1).toInt());
    }
    else
    {
        subjectStartPoint = subjectEndPoint = QPoint();
    }

    QVariant optionStartPointSetting = config->readConfig(CONFIG_EXAM, "optionStartPoint");
    QVariant optionEndPointSetting = config->readConfig(CONFIG_EXAM, "optionEndPoint");
    if (!optionStartPointSetting.isNull() && !optionEndPointSetting.isNull())
    {
        ui->selectOptionButton->setProperty("rectSelected", true);
        ui->selectOptionButton->style()->polish(ui->selectOptionButton);
        optionStartPoint = QPoint(optionStartPointSetting.toString().split(",").at(0).toInt(), optionStartPointSetting.toString().split(",").at(1).toInt());
        optionEndPoint = QPoint(optionEndPointSetting.toString().split(",").at(0).toInt(), optionEndPointSetting.toString().split(",").at(1).toInt());
    }
    else
    {
        optionStartPoint = optionEndPoint = QPoint();
    }

    QVariant confirmationPointSetting= config->readConfig(CONFIG_EXAM, "confirmationPoint");
    if (!confirmationPointSetting.isNull())
    {
        ui->pickConfirmationButton->setProperty("optionPicked", true);
        ui->pickConfirmationButton->style()->polish(ui->pickConfirmationButton);
        confirmationPoint = QPoint(confirmationPointSetting.toString().split(",").at(0).toInt(), confirmationPointSetting.toString().split(",").at(1).toInt());
    }
    else
    {
        confirmationPoint = QPoint();
    }
    QVariant submissionPointSetting = config->readConfig(CONFIG_EXAM, "submissionPoint");
    if (!submissionPointSetting.isNull())
    {
        ui->pickSubmissionButton->setProperty("optionPicked", true);
        ui->pickSubmissionButton->style()->polish(ui->pickSubmissionButton);
        submissionPoint = QPoint(submissionPointSetting.toString().split(",").at(0).toInt(), submissionPointSetting.toString().split(",").at(1).toInt());
    }
    else
    {
        submissionPoint = QPoint();
    }
}

void Widget::initSubjects()
{
    this->initOneSubject("单选题：李太白有诗云：“红罗袖里分明见，白玉盘中看却无。疑是老僧休念诵，腕前推下水精珠。”此诗题为？", "《白胡桃》");
}


void Widget::initOneSubject(QString question, QString answer)
{
    QJsonObject jsonObj;
    jsonObj["question"] = question;
    jsonObj["answer"] = answer;
    QJsonDocument jsonDoc = QJsonDocument(jsonObj);
    QString jsonString = jsonDoc.toJson(QJsonDocument::Compact);
    subjects->writeConfig(SUBJECT_JP, chineseToJP(question), jsonString);
}

void Widget::getOcrAccessToken()
{
    QVariant tokenSetting = config->readConfig(CONFIG_OCR, "token");
    QVariant createAtSetting = config->readConfig(CONFIG_OCR, "createAt");
    boolean refresh = tokenSetting.isNull() || createAtSetting.isNull() || QDateTime::currentDateTime().toSecsSinceEpoch() - createAtSetting.toInt() > 60*60*28;
    if (refresh)
    {
        accessToken = detectWords->getAccessToken();
        qint64 createAt = QDateTime::currentDateTime().toSecsSinceEpoch();
        config->writeConfig(CONFIG_OCR, "token", accessToken);
        config->writeConfig(CONFIG_OCR, "createAt", createAt);
    }
    else
    {
        accessToken = tokenSetting.toString();
    }
}

void Widget::leftClick(QPoint point)
{
    SetCursorPos(point.x(), point.y());
    mouse_event(MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE, point.x()*65535/screen->size().width(), point.y()*65535/screen->size().height(), 0, GetMessageExtraInfo());
    QThread::msleep(1000);
    // mouse_event(MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_LEFTDOWN, point.x(), point.y(), 0, 0);
    // QThread::msleep(1000);
    // mouse_event(MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_LEFTUP, point.x(), point.y(), 0, 0);
    // QThread::msleep(1000);
}

void Widget::completeSubject()
{
    if (subjectStartPoint == QPoint() || subjectEndPoint == QPoint()
        || optionStartPoint == QPoint() || optionEndPoint == QPoint()
        || submissionPoint == QPoint() || confirmationPoint == QPoint())
    {
        ui->questionLabel->setText("请完成设置后开始考试ヾ(◍°∇°◍)ﾉﾞ");
    }
    QJsonArray subjectArray = detectWords->ocrAccurateBasic(accessToken, QRect(subjectStartPoint, subjectEndPoint));
    bool recognised = false;
    QString subjectJp;
    QStringList subjectList;
    QString question, answer;
    if (!subjectArray.isEmpty())
    {
        for (int i = 0; i < subjectArray.size(); i ++)
        {
            QJsonValue value = subjectArray.at(i);
            QJsonObject obj = value.toObject();
            QString text = obj.value("words").toString();

            if (text.startsWith("单选题："))
            {
                recognised = true;
            }
            subjectJp.append(this->chineseToJP(text));
            subjectList.append(text);
            qDebug() << "识别到题目：" << value;
        }
    }
    if (!recognised)
    {
        ui->questionLabel->setText("没有识别到题目o(╥﹏╥)o");
        return;
    }
    else
    {
        ui->questionLabel->setText("正在从本地题库搜索~");
        QVariant answerSetting = subjects->readConfig(SUBJECT_JP, subjectJp);
        qDebug() << answerSetting;
        if (!answerSetting.isNull())
        {
            QJsonDocument jsonDocument = QJsonDocument::fromJson(answerSetting.toString().toUtf8());
            QJsonObject jsonObject = jsonDocument.object();

            question = jsonObject.value("question").toString();
            answer = jsonObject.value("answer").toString();
            ui->questionLabel->setText(question);
        }
        else
        {
            bool answerGot = false;
            ui->questionLabel->setText("正在从在线题库搜索~");
            QJsonObject result = detectWords->queryWithJx3Api(subjectJp);
            if (!result.isEmpty())
            {
                answerGot = true;
                question = result.value("question").toString();
                answer = result.value("answer").toString();
                ui->questionLabel->setText(question);
            }
            else
            {
                foreach (QString text, subjectList) {
                    result = detectWords->queryWithJx3Api(text);
                    if (!result.isEmpty())
                    {
                        answerGot = true;
                        question = result.value("question").toString();
                        answer = result.value("answer").toString();
                        ui->questionLabel->setText(question);
                        break;
                    }
                }

            }

            if (answerGot)
            {
                this->initOneSubject(question, answer);
            }
            else
            {
                ui->questionLabel->setText("没有查询到答案[○･｀Д´･ ○]");
                return ;
            }
        }
    }
    QJsonArray optionArray = detectWords->ocrAccurate(accessToken, QRect(optionStartPoint, optionEndPoint));
    if (!optionArray.isEmpty())
    {
        QString optionStr;
        for (int i = 0; i < optionArray.size(); i ++)
        {
            QJsonValue value = optionArray.at(i);
            QJsonObject obj = value.toObject();
            QString text = obj.value("words").toString();
            QJsonObject location = obj.value("location").toObject();
            qDebug() << "识别到选项：" << value;
            if (text == answer)
            {
                optionStr.append("<strong style='color: red;'>").append(QString::number(i+1)).append(". ").append(text).append("</strong><br><br>");

                int answerX = location.value("left").toInt();
                int answerY = location.value("top").toInt();
                int answerWidth = location.value("width").toInt();
                int answerHeight = location.value("height").toInt();
                qDebug() << answerX << " " << answerY << " " << answerWidth << " " << answerHeight;
                this->leftClick(QPoint(answerX + answerWidth/2 + optionStartPoint.x(), answerY + answerHeight/2 + optionStartPoint.y()));
            }
            else
            {
                optionStr.append(QString::number(i+1)).append(". ").append(text).append("<br><br>");
            }
        }
        ui->answerLabel->setText(optionStr);
    }
    else
    {
        ui->questionLabel->setText("没有识别到选项_(¦3」∠)_");
    }

}

void Widget::start()
{
    if (state == 1)
    {
        return;
    }
    state = 1;
    ui->tabWidget->setEnabled(false);
    if (soundSwitch)
    {
        soundEffect->setSource(QUrl::fromLocalFile(":/sound/start.wav"));
        soundEffect->play();
    }
    if (currentTab == 0)
    {
        this->showMinimized();
        if (generalSwitch1)
        {
            generalThread1 = new KeyThread(generalKey1, generalInterval1);
            generalThread1->setState(state);
            generalThread1->start();
        }
        if (generalSwitch2)
        {
            generalThread2 = new KeyThread(generalKey2, generalInterval2);
            generalThread2->setState(state);
            generalThread2->start();
        }
        if (generalSwitch3)
        {
            generalThread3 = new KeyThread(generalKey3, generalInterval3);
            generalThread3->setState(state);
            generalThread3->start();
        }
        if (generalSwitch4)
        {
            generalThread4 = new KeyThread(generalKey4, generalInterval4);
            generalThread4->setState(state);
            generalThread4->start();
        }
    }
    else if (currentTab == 1)
    {
        completeSubject();

    }
    qDebug() << this->formatState(state);
}


void Widget::pause()
{
    if (state == 0)
    {
        return;
    }

    if (state == 1)
    {
        state = 2;
        if (soundSwitch)
        {
            soundEffect->setSource(QUrl::fromLocalFile(":/sound/stop.wav"));   // todo  暂停
            soundEffect->play();
        }
    }
    else if (state == 2)
    {
        state = 1;
        if (soundSwitch)
        {
            soundEffect->setSource(QUrl::fromLocalFile(":/sound/start.wav"));
            soundEffect->play();
        }
    }
    if (currentTab == 0)
    {
        if (generalSwitch1)
        {
            generalThread1->setState(state);
        }
        if (generalSwitch2)
        {
            generalThread2->setState(state);
        }
        if (generalSwitch3)
        {
            generalThread3->setState(state);
        }
        if (generalSwitch4)
        {
            generalThread4->setState(state);
        }
    }
    qDebug() << this->formatState(state);
}


void Widget::stop()
{
    if (state == 0)
    {
        return;
    }
    state = 0;
    ui->tabWidget->setEnabled(true);
    if (soundSwitch)
    {
        soundEffect->setSource(QUrl::fromLocalFile(":/sound/stop.wav"));
        soundEffect->play();
    }
    if (currentTab == 0)
    {
        this->showNormal();
        if (generalSwitch1)
        {
            generalThread1->terminate();
        }
        if (generalSwitch2)
        {
            generalThread2->terminate();
        }
        if (generalSwitch3)
        {
            generalThread3->terminate();
        }
        if (generalSwitch4)
        {
            generalThread4->terminate();
        }
    }
    qDebug() << this->formatState(state);
}

QString Widget::formatState (int state)
{
    QString s;
    switch(state){
    case 0:
        s = "已停止";
        break;
    case 1:
        s = "运行中";
        break;
    case 2:
        s = "已暂停";
        break;
    default:
        s = QChar(state);
    }
    return s;
}

void Widget::keyPressEvent(QKeyEvent *k)
{

}

void Widget::initFunctionKeys()
{
    functionKeys.insert(VK_F1, "F1");
    functionKeys.insert(VK_F2, "F2");
    functionKeys.insert(VK_F3, "F3");
    functionKeys.insert(VK_F4, "F4");
    functionKeys.insert(VK_F5, "F5");
    functionKeys.insert(VK_F6, "F6");
    functionKeys.insert(VK_F7, "F7");
    functionKeys.insert(VK_F8, "F8");
    functionKeys.insert(VK_F9, "F9");
    functionKeys.insert(VK_F10, "F10");
    functionKeys.insert(VK_F11, "F11");
    functionKeys.insert(VK_F12, "F12");
    for(auto it = functionKeys.begin(); it != functionKeys.end(); it++)
    {
        ui->startCombobox->addItem(it.value(),it.key());
        ui->pauseCombobox->addItem(it.value(),it.key());
        ui->stopComboBox->addItem(it.value(),it.key());
    }
}

void Widget::initListJP()
{
    listJP << "YDYQSXMWZSSXJBYMGCCZQPSSQBYCDSCDQLDYLYBSSJGYZZJJFKCCLZDHWDWZJLJPFYYNWJJTMYHZWZHFLZPPQHGSCYYYNJQYXXGJ";
    listJP << "HHSDSJNKKTMOMLCRXYPSNQSECCQZGGLLYJLMYZZSECYKYYHQWJSSGGYXYZYJWWKDJHYCHMYXJTLXJYQBYXZLDWRDJRWYSRLDZJPC";
    listJP << "BZJJBRCFTLECZSTZFXXZHTRQHYBDLYCZSSYMMRFMYQZPWWJJYFCRWFDFZQPYDDWYXKYJAWJFFXYPSFTZYHHYZYSWCJYXSCLCXXWZ";
    listJP << "ZXNBGNNXBXLZSZSBSGPYSYZDHMDZBQBZCWDZZYYTZHBTSYYBZGNTNXQYWQSKBPHHLXGYBFMJEBJHHGQTJCYSXSTKZHLYCKGLYSMZ";
    listJP << "XYALMELDCCXGZYRJXSDLTYZCQKCNNJWHJTZZCQLJSTSTBNXBTYXCEQXGKWJYFLZQLYHYXSPSFXLMPBYSXXXYDJCZYLLLSJXFHJXP";
    listJP << "JBTFFYABYXBHZZBJYZLWLCZGGBTSSMDTJZXPTHYQTGLJSCQFZKJZJQNLZWLSLHDZBWJNCJZYZSQQYCQYRZCJJWYBRTWPYFTWEXCS";
    listJP << "KDZCTBZHYZZYYJXZCFFZZMJYXXSDZZOTTBZLQWFCKSZSXFYRLNYJMBDTHJXSQQCCSBXYYTSYFBXDZTGBCNSLCYZZPSAZYZZSCJCS";
    listJP << "HZQYDXLBPJLLMQXTYDZXSQJTZPXLCGLQTZWJBHCTSYJSFXYEJJTLBGXSXJMYJQQPFZASYJNTYDJXKJCDJSZCBARTDCLYJQMWNQNC";
    listJP << "LLLKBYBZZSYHQQLTWLCCXTXLLZNTYLNEWYZYXCZXXGRKRMTCNDNJTSYYSSDQDGHSDBJGHRWRQLYBGLXHLGTGXBQJDZPYJSJYJCTM";
    listJP << "RNYMGRZJCZGJMZMGXMPRYXKJNYMSGMZJYMKMFXMLDTG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LLJQKYGZMCYZZYM";
    listJP << "CCSLCLHZFWFWYXZMWSXTYNXJHPYYMCYSPMHYSMYDYSHQYZCHMJJMZCAAGCFJBBHPLYZYLXXSDJGXDHKXXTXXNBHRMLYJSLTXMRHN";
    listJP << "LXQJXYZLLYSWQGDLBJHDCGJYQYCMHWFMJYBMBYJYJWYMDPWHXQLDYGPDFXXBCGJSPCKRSSYZJMSLBZZJFLJJJLGXZGYXYXLSZQYX";
    listJP << "BEXYXHGCXBPLDYHWETTWWCJMBTXCHXYQXLLXFLYXLLJLSSFWDPZSMYJCLMWYTCZPCHQEKCQBWLCQYDPLQPPQZQFJQDJHYMMCXTXD";
    listJP << "RMJWRHXCJZYLQXDYYNHYYHRSLSRSYWWZJYMTLTLLGTQCJZYABTCKZCJYCCQLJZQXALMZYHYWLWDXZXQDLLQSHGPJFJLJHJABCQZD";
    listJP << "JGTKHSSTCYJLPSWZLXZXRWGLDLZRLZXTGSLLLLZLYXXWGDZYGBDPHZPBRLWSXQBPFDWOFMWHLYPCBJCCLDMBZPBZZLCYQXLDOMZB";
    listJP << "LZWPDWYYGDSTTHCSQSCCRSSSYSLFYBFNTYJSZDFNDPDHDZZMBBLSLCMYFFGTJJQWFTMTPJWFNLBZCMMJTGBDZLQLPYFHYYMJYLSD";
    listJP << "CHDZJWJCCTLJCLDTLJJCPDDSQDSSZYBNDBJLGGJZXSXNLYCYBJXQYCBYLZCFZPPGKCXZDZFZTJJFJSJXZBNZYJQTTYJYHTYCZHYM";
    listJP << "DJXTTMPXSPLZCDWSLSHXYPZGTFMLCJTYCBPMGDKWYCYZCDSZZYHFLYCTYGWHKJYYLSJCXGYWJCBLLCSNDDBTZBSCLYZCZZSSQDLL";
    listJP << "MQYYHFSLQLLXFTYHABXGWNYWYYPLLSDLDLLBJCYXJZMLHLJDXYYQYTDLLLBUGBFDFBBQJZZMDPJHGCLGMJJPGAEHHBWCQXAXHHHZ";
    listJP << "CHXYPHJAXHLPHJPGPZJQCQZGJJZZUZDMQ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QEEWXKSYYKDYPLTJTHKJLTCYYHH";
    listJP << "JTTPLTZZCDLTHQKZXQYSTEEYWYYZYXXYYSTTJKLLPZMCYHQGXYHSRMBXPLLNQYDQHXSXXWGDQBSHYLLPJJJTHYJKYPPTHYYKTYEZ";
    listJP << "YENMDSHLCRPQFDGFXZPSFTLJXXJBSWYYSKSFLXLPPLBBBLBSFXFYZBSJSSYLPBBFFFFSSCJDSTZSXZRYYSYFFSYZYZBJTBCTSBSD";
    listJP << "HRTJJBYTCXYJEYLXCBNEBJDSYXYKGSJZBXBYTFZWGENYHHTHZHHXFWGCSTBGXKLSXYWMTMBYXJSTZSCDYQRCYTWXZFHMYMCXLZNS";
    listJP << "DJTTTXRYCFYJSBSDYERXJLJXBBDEYNJGHXGCKGSCYMBLXJMSZNSKGXFBNBPTHFJAAFXYXFPXMYPQDTZCXZZPXRSYWZDLYBBKTYQP";
    listJP << "QJPZYPZJZNJPZJLZZFYSBTTSLMPTZRTDXQSJEHBZYLZDHLJSQMLHTXTJECXSLZZSPKTLZKQQYFSYGYWPCPQFHQHYTQXZKRSGTTSQ";
    listJP << "CZLPTXCDYYZXSQZSLXLZMYCPCQBZYXHBSXLZDLTCDXTYLZJYYZPZYZLTXJSJXHLPMYTXCQRBLZSSFJZZTNJYTXMYJHLHPPLCYXQJ";
    listJP << "QQKZZSCPZKSWALQSBLCCZJSXGWWWYGYKTJBBZTDKHXHKGTGPBKQYSLPXPJCKBMLLXDZSTBKLGGQKQLSBKKTFXRMDKBFTPZFRTBBR";
    listJP << "FERQGXYJPZSSTLBZTPSZQZSJDHLJQLZBPMSMMSXLQQNHKNBLRDDNXXDHDDJCYYGYLXGZLXSYGMQQGKHBPMXYXLYTQWLWGCPBMQXC";
    listJP << "YZYDRJBHTDJYHQSHTMJSBYPLWHLZFFNYPMHXXHPLTBQPFBJWQDBYGPNZTPFZJGSDDTQSHZEAWZZYLLTYYBWJKXXGHLFKXDJTMSZS";
    listJP << "QYNZGGSWQSPHTLSSKMCL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PWPYMLGKDLDLGKQQBGYCHJ";
    listJP << "XY";
}

void Widget::selectStartKey(int index)
{
    if (initializing)
    {
        return;
    }
    int tempStartKeyInt = ui->startCombobox->itemData(index).toInt();
    if (tempStartKeyInt == pauseKey)
    {
        QMessageBox::warning(this, "警告", "当前键位与'暂停'键位冲突，请重新设置。");
        ui->startCombobox->setCurrentText(functionKeys[startKey]);
    }
    else
    {
        startKey = tempStartKeyInt;
    }
    ui->startButton->setText("开始 (" + functionKeys[startKey] + ")");
    config->writeConfig(CONFIG_COMMON, "start", startKey);
}


void Widget::selectPauseKey(int index)
{
    if (initializing)
    {
        return;
    }
    int tempPauseKeyInt = ui->pauseCombobox->itemData(index).toInt();
    if (tempPauseKeyInt == startKey)
    {
        QMessageBox::warning(this, "警告", "当前键位与 开始 键位冲突，请重新设置。");
        ui->pauseCombobox->setCurrentText(functionKeys[pauseKey]);
    }
    else if (tempPauseKeyInt == stopKey)
    {
        QMessageBox::warning(this, "警告", "当前键位与 结束 键位冲突，请重新设置。");
        ui->pauseCombobox->setCurrentText(functionKeys[pauseKey]);
    }
    else
    {
        pauseKey = tempPauseKeyInt;
    }
    ui->pauseButton->setText("暂停 (" + functionKeys[pauseKey] + ")");
    config->writeConfig(CONFIG_COMMON, "pause", pauseKey);
}


void Widget::selectStopKey(int index)
{
    if (initializing)
    {
        return;
    }
    int tempStopKeyInt = ui->stopComboBox->itemData(index).toInt();
    if (tempStopKeyInt == pauseKey)
    {
        QMessageBox::warning(this, "警告", "当前键位与 暂停 键位冲突，请重新设置。");
        ui->stopComboBox->setCurrentText(functionKeys[stopKey]);
    }
    else
    {
        stopKey = tempStopKeyInt;
    }
    ui->stopButton->setText("结束 (" + functionKeys[stopKey] + ")");
    config->writeConfig(CONFIG_COMMON, "stop", stopKey);
}

void Widget::selectQuitMode(int index)
{
    config->writeConfig(CONFIG_COMMON, "quitMode", index);
}

void Widget::toggleSoundSwitch(bool state)
{
    soundSwitch = state;
    config->writeConfig(CONFIG_COMMON, "soundSwitch", state);
}

void Widget::initTray()
{
    tray= new QSystemTrayIcon(this);
    tray->setIcon(QIcon(":/icon/icon3.png"));
    tray->setToolTip(qApp->applicationName());
    tray->show();

    QAction* restoreAction = new QAction("还原", this);
    connect(restoreAction, SIGNAL(triggered()), this, SLOT(showNormal()));
    QAction* quitAction = new QAction("退出", this);
    connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));

    trayMenu = new QMenu(this);
    trayMenu->addAction(restoreAction);
    trayMenu->addSeparator();
    trayMenu->addAction(quitAction);
    tray->setContextMenu(trayMenu);
    tray->hide();

    connect(tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));
}

void Widget::iconActivated(QSystemTrayIcon::ActivationReason ireason)
{
    switch (ireason)
    {
    case QSystemTrayIcon::Trigger:
        break;
    case QSystemTrayIcon::DoubleClick:
        this->showNormal();
        tray->hide();
        break;
    case QSystemTrayIcon::MiddleClick:
        break;
    default:
        break;
    }
}

void Widget::closeEvent(QCloseEvent *event)
{
    int quitMode = 0;
    QVariant quitModeSetting = config->readConfig(CONFIG_COMMON, "quitMode");
    if (quitModeSetting.isNull())
    {
        QMessageBox mess(QMessageBox::Question, tr("按键"), tr("是否确定退出？"));
        QPushButton *trayButton = mess.addButton(tr("最小化到托盘"), QMessageBox::NoRole);
        QPushButton *exitButton = mess.addButton(tr("直接退出"), QMessageBox::YesRole);
        mess.setWindowIcon(QIcon(":/icon/icon3.png"));
        trayButton->setFocus();
        mess.exec();
        if (mess.clickedButton() == exitButton)
        {
            quitMode = 1;
        }
        else if (mess.clickedButton() == trayButton)
        {
            quitMode = 0;
        }
        config->writeConfig(CONFIG_COMMON, "quitMode", quitMode);
    }
    else {
        quitMode = quitModeSetting.toInt();
    }

    if (quitMode == 1)
    {
        event->accept();
    }
    else if (quitMode == 0)
    {
        hide();
        tray->show();
        tray->showMessage("按键", "已转入后台运行", QSystemTrayIcon::Information, 500);
        event->ignore();
    }
}

void Widget::mousePressEvent(QMouseEvent *event)
{

}

void Widget::onKeyEventReceived(int vkCode){
    if (state != 1 && vkCode == startKey)
    {
        start();
        return;
    }
    if (state != 0 && vkCode == pauseKey)
    {
        pause();
        return;
    }
    if (state != 0 && vkCode == stopKey)
    {
        stop();
        return;
    }
}

void Widget::onMouseEventReceived(int x, int y, QString button)
{
    // 钩子在剑三界面不生效。
    if (state == 1 && currentTab == 1 && button == "左键")
    {
        if (qAbs(x-submissionPoint.x())<20 && qAbs(y-submissionPoint.y())<10)
        {
            QThread::msleep(1000);
            this->completeSubject();
        }
        if (qAbs(x-confirmationPoint.x())<20 && qAbs(y-confirmationPoint.y())<10)
        {
            qDebug() << "点击了confirmation";
            ui->questionLabel->setText("考试完成✿✿ヽ(°▽°)ノ✿");
            ui->answerLabel->setText("");
            this->stop();
        }
    }
}


void Widget::changeTab(int index)
{
    if (index == 0)
    {
        qDebug() << "切换tab页： common";
        this->setWindowFlags(this->windowFlags() & ~Qt::WindowStaysOnTopHint);
        this->showNormal();

    }
    else if (index == 1)
    {
        this->setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint);
        this->showNormal();

    }
    else
    {
        qDebug() << "切换到页面： setting";
        this->setWindowFlags(this->windowFlags() & ~Qt::WindowStaysOnTopHint);
        this->showNormal();
    }
    currentTab = index;
}

bool Widget::validKeyValue(Qt::Key key)
{
    if (key >= Qt::Key_0 && key <= Qt::Key_9)
    {
        return true;
    }
    if (key >= Qt::Key_A && key <= Qt::Key_Z)
    {
        return true;
    }
    if (key >= Qt::Key_F1 && key <= Qt::Key_F12)
    {
        return true;
    }
    return false;
}
void Widget::toggleGeneralSwitch1(bool state)
{
    if (state == true && generalKey1 == 0)
    {
        QMessageBox::information(this, "提示", "请先录入 按键·壹 的键值。");
        ui->generalSwitch1->setCheckedState(false);
        generalSwitch1 = false;
        config->writeConfig(CONFIG_COMMON, "generalSwitch1", false);
    }
    generalSwitch1 = state;
    config->writeConfig(CONFIG_COMMON, "generalSwitch1", state);
}

void Widget::setGeneralKey1(){
    Qt::Key key = ui->generalKey1->keySequence()[0].key();
    if (this->validKeyValue(key))
    {
        generalKey1 = key;
    }
    else
    {
        generalKey1 = 0;
        ui->generalSwitch1->setCheckedState(false);
        generalSwitch1 = false;
        config->writeConfig(CONFIG_COMMON, "generalSwitch1", false);
    }
    ui->generalKey1->setKeySequence(QKeySequence(key));
    config->writeConfig(CONFIG_COMMON, "generalKey1", key);
}

void Widget::setGeneralInterval1(){
    int interval1 = ui->generalInterval1->value();
    generalInterval1 = interval1;
    config->writeConfig(CONFIG_COMMON, "generalInterval1", interval1);
}

void Widget::toggleGeneralSwitch2(bool state)
{
    if (state == true && generalKey2 == 0)
    {
        QMessageBox::information(this, "提示", "请先录入 按键·贰 的键值。");
        ui->generalSwitch2->setCheckedState(false);
        generalSwitch2 = false;
        config->writeConfig(CONFIG_COMMON, "generalSwitch2", false);
    }
    generalSwitch2 = state;
    config->writeConfig(CONFIG_COMMON, "generalSwitch2", state);
}

void Widget::setGeneralKey2(){
    Qt::Key key = ui->generalKey2->keySequence()[0].key();
    if (this->validKeyValue(key))
    {
        generalKey2 = key;
    }
    else
    {
        generalKey2 = 0;
        ui->generalSwitch2->setCheckedState(false);
        generalSwitch2 = false;
        config->writeConfig(CONFIG_COMMON, "generalSwitch2", false);
    }
    ui->generalKey2->setKeySequence(QKeySequence(key));
    config->writeConfig(CONFIG_COMMON, "generalKey2", key);
}

void Widget::setGeneralInterval2(){
    int interval2 = ui->generalInterval2->value();
    generalInterval2 = interval2;
    config->writeConfig(CONFIG_COMMON, "generalInterval2", interval2);
}

void Widget::toggleGeneralSwitch3(bool state)
{
    if (state == true && generalKey3 == 0)
    {
        QMessageBox::information(this, "提示", "请先录入 按键·叁 的键值。");
        ui->generalSwitch3->setCheckedState(false);
        generalSwitch3 = false;
        config->writeConfig(CONFIG_COMMON, "generalSwitch3", false);
    }
    generalSwitch3 = state;
    config->writeConfig(CONFIG_COMMON, "generalSwitch3", state);
}

void Widget::setGeneralKey3(){
    Qt::Key key = ui->generalKey3->keySequence()[0].key();
    if (this->validKeyValue(key))
    {
        generalKey3 = key;
    }
    else
    {
        generalKey3 = 0;
        ui->generalSwitch3->setCheckedState(false);
        generalSwitch3 = false;
        config->writeConfig(CONFIG_COMMON, "generalSwitch3", false);
    }
    ui->generalKey3->setKeySequence(QKeySequence(key));
    config->writeConfig(CONFIG_COMMON, "generalKey3", key);
}

void Widget::setGeneralInterval3(){
    int interval3 = ui->generalInterval3->value();
    generalInterval3 = interval3;
    config->writeConfig(CONFIG_COMMON, "generalInterval3", interval3);
}

void Widget::toggleGeneralSwitch4(bool state)
{
    if (state == true && generalKey4 == 0)
    {
        QMessageBox::information(this, "提示", "请先录入 按键·肆 的键值。");
        ui->generalSwitch4->setCheckedState(false);
        generalSwitch4 = false;
        config->writeConfig(CONFIG_COMMON, "generalSwitch4", false);
    }
    generalSwitch4 = state;
    config->writeConfig(CONFIG_COMMON, "generalSwitch4", state);
}

void Widget::setGeneralKey4(){
    Qt::Key key = ui->generalKey4->keySequence()[0].key();
    if (this->validKeyValue(key))
    {
        generalKey4 = key;
    }
    else
    {
        generalKey4 = 0;
        ui->generalSwitch4->setCheckedState(false);
        generalSwitch4 = false;
        config->writeConfig(CONFIG_COMMON, "generalSwitch4", false);
    }
    ui->generalKey4->setKeySequence(QKeySequence(key));
    config->writeConfig(CONFIG_COMMON, "generalKey4", key);
}

void Widget::setGeneralInterval4(){
    int interval4 = ui->generalInterval4->value();
    generalInterval4 = interval4;
    config->writeConfig(CONFIG_COMMON, "generalInterval4", interval4);
}

void Widget::tryBindingWindow()
{
    this->showMinimized();
    QThread::sleep(2);
    HWND targetWindowHandle = GetForegroundWindow();

    // 将HWND转换为QWindow对象
    QWindow *targetWindow = QWindow::fromWinId((WId)targetWindowHandle);

    // 获取目标窗口的句柄
    targetWindowId = targetWindow->winId();

    char title[256];

    this->showNormal();
    if (targetWindowHandle == NULL)
    {
        ui->currentWinLabel->setText("当前未绑定程序，按键全局生效");
    }
    else
    {
        GetWindowTextA(targetWindowHandle, title, sizeof(title));
        ui->currentWinLabel->setText(title);
    }
}

void Widget::selectSubjectRect()
{
    qDebug() << "开始框选题干区域";
    this->setWindowOpacity(0);
    screenShot = new ScreenShot(screen, subjectStartPoint, subjectEndPoint, targetWindowId, 1);
    connect(screenShot, &ScreenShot::rectConfirmed, this, &Widget::saveRectPosition);
    screenShot->showFullScreen();
    this->setWindowOpacity(1);
}

void Widget::selectOptionRect()
{
    this->setWindowOpacity(0);
    screenShot = new ScreenShot(screen, optionStartPoint, optionEndPoint, targetWindowId, 2);
    connect(screenShot, &ScreenShot::rectConfirmed, this, &Widget::saveRectPosition);
    screenShot->showFullScreen();
    this->setWindowOpacity(1);
}

void Widget::saveRectPosition(QRect rect, int index)
{
    QString startPointStr, endPointStr;
    switch(index)
    {
    case 1:
        ui->selectSubjectButton->setProperty("rectSelected", true);
        ui->selectSubjectButton->style()->polish(ui->selectSubjectButton);
        qDebug() << rect;
        subjectStartPoint = QPoint(rect.left(), rect.top());
        subjectEndPoint = QPoint(rect.right(), rect.bottom());
        qDebug() << "subject point: " << subjectStartPoint << " " << subjectEndPoint;
        startPointStr = QString("%1,%2").arg(rect.left()).arg(rect.top());
        endPointStr = QString("%1,%2").arg(rect.right()).arg(rect.bottom());
        config->writeConfig(CONFIG_EXAM, "subjectStartPoint", startPointStr);
        config->writeConfig(CONFIG_EXAM, "subjectEndPoint", endPointStr);
        break;
    case 2:
        ui->selectOptionButton->setProperty("rectSelected", true);
        ui->selectOptionButton->style()->polish(ui->selectOptionButton);
        qDebug() << rect;
        optionStartPoint = QPoint(rect.left(), rect.top());
        optionEndPoint = QPoint(rect.right(), rect.bottom());
        qDebug() << "subject point: " << optionStartPoint << " " << optionEndPoint;
        startPointStr = QString("%1,%2").arg(rect.left()).arg(rect.top());
        endPointStr = QString("%1,%2").arg(rect.right()).arg(rect.bottom());
        config->writeConfig(CONFIG_EXAM, "optionStartPoint", startPointStr);
        config->writeConfig(CONFIG_EXAM, "optionEndPoint", endPointStr);
        break;
    default:
        qDebug() << "参数错误";
    }
}

void Widget::pickConfirmation()
{
    this->setWindowOpacity(0);
    pickPoint = new PickPoint(screen, confirmationPoint, targetWindowId, 1);
    connect(pickPoint, &PickPoint::pointConfirmed, this, &Widget::saveOptionPoint);
    pickPoint->showFullScreen();
    this->setWindowOpacity(1);
}

void Widget::pickSubmission()
{
    this->setWindowOpacity(0);
    pickPoint = new PickPoint(screen, submissionPoint, targetWindowId, 9);
    connect(pickPoint, &PickPoint::pointConfirmed, this, &Widget::saveOptionPoint);
    pickPoint->showFullScreen();
    this->setWindowOpacity(1);
}

void Widget::saveOptionPoint(QPoint point, int index)
{
    QString optionPointStr;
    switch(index){
        case 1:
            ui->pickConfirmationButton->setProperty("optionPicked", true);
            ui->pickConfirmationButton->style()->polish(ui->pickConfirmationButton);
            confirmationPoint = point;
            optionPointStr = QString("%1,%2").arg(point.x()).arg(point.y());
            config->writeConfig(CONFIG_EXAM, "confirmationPoint", optionPointStr);
            break;
        case 9:
            ui->pickSubmissionButton->setProperty("optionPicked", true);
            ui->pickSubmissionButton->style()->polish(ui->pickSubmissionButton);
            submissionPoint = point;
            optionPointStr = QString("%1,%2").arg(point.x()).arg(point.y());
            config->writeConfig(CONFIG_EXAM, "submissionPoint", optionPointStr);
            break;
        default:
            qDebug() << "参数错误";
    }

}

QString Widget::chineseToJP(QString &chinese)
{
    QString listJPStr = listJP.join("");
    if (chinese.length() == 0) {
        return chinese;
    }
    QString result;
    for (int i=0; i<chinese.length(); i++)
    {
        int unicode = QString::number(chinese.at(i).unicode(), 10).toInt();
        if (unicode >=0x4E00 && unicode <0x9FA5)
        {
            result.append(listJPStr.at(unicode - 0x4E00));
        }
    }
    return result;
}
